<?php
  $noSeasonChange = true;
  include_once("includes/header.php");
  $submit = $_POST["submit"];
  if (isset($submit)) {
    if (isCommissioner()) {
	  $year = $_POST["year"];
	  $month = $_POST["month"];
	  $day = $_POST["day"];
	  $type = $_POST["type"];
	  $news = $_POST["news"];
      if (strlen($type) > 0 and strlen($news) > 0) {
        $rs = executeQuery("insert into news values ('$year-$month-$day', '$type', '$news')");
        if ($rs) {
          echo "<tr><td colspan=2>News Added</td></tr>";
        } else {
          echo "<tr><td colspan=2>Addition Failed</td></tr>";
        }
      } else {
        echo "<tr><td colspan=2>You must supply a type and some news</td></tr>";
      }
    } else {
      echo "<tr><td colspan=2>Sorry you cannot edit the news</td></tr>";
    }
  }
echo <<< EOQ
  <caption><h3>News Submission</h3></caption>
  <form method="post">
    <tr>
      <td colspan="2">
EOQ;
  $months = array("Jan", "Feb", "Mar",  "Apr",  "May",  "Jun",  "Jul",  "Aug",  "Sep",  "Oct", "Nov", "Dec");
  $day = date("j");
  $month = date("m");
  $year = date("Y");
  include("includes/date.php");
echo <<< EOQ
      </td>
    </tr>
    <tr>
      <th>Type</th>
      <td><input type="text" name="type" value="$type" size="32"></td>
    </tr>
    <tr>
      <th>News</th>
      <td>
        <textarea name="news" rows="5" cols="75">$news</textarea>
      </td>
    </tr>
    <tr>
      <th colspan="2"><input type="submit" value="submit" name="submit"></th>
    </tr>
EOQ;
  include("includes/footer.php");
?>
